#!/usr/bin/env bash

DATADIR=/home/dig/graph_data/correct_data
REMOTEDIR="/home/nfs/server-download-dir/correct_data"
REMOTE_ADDR=172.18.180.228
cd ${DATADIR}
for l in `ls ${DATADIR}|grep  tgz`;do 
    try_cnt=0
    while [ $try_cnt -lt 4 ];
        do
            rsync --append --partial --progress -e "ssh -p22" ${l} work@${REMOTE_ADDR}:${REMOTEDIR}/
            ret=$?
            if [ "$ret" != "0" ];then
                echo "sync failed"
            else break
            fi
            try_cnt=`expr ${try_cnt} + 1`
            if [ ${try_cnt} -ge 4 ];then
                echo "传输失败次数超过4次, 退出..."
                exit -1
            fi
        done
done
